package de.szut.ita13sommerfeld.apacheanalyser.commander;

import java.io.File;
import de.szut.ita13sommerfeld.apacheanalyser.components.ApacheComponent;
import de.szut.ita13sommerfeld.apacheanalyser.handler.ApacheHandler;

public class ApacheCommanderInterpreter {

	public static final int OPTION_LOG_FILE = 0, OPTION_STATISTICS_FILE= 1;
	
	
	private ApacheComponent[] components;
	private ApacheCommander commander;
	private ApacheHandler apachehandler;
	
	/**
	 * 
	 * @param commander is the commander that will be interpretate
	 */
	public ApacheCommanderInterpreter(ApacheComponent[] components) {
		this.components = components;
		commander = (ApacheCommander)this.components[0];
		apachehandler = (ApacheHandler)this.components[1];
	}
	
	/**
	 * 
	 * @return returns if the commander has commands 
	 */
	
	public boolean hasCommands() {
		return commander.getCommands().length > 0;
	}
	
	/**
	 * start parsing in the commander
	 */
	public void initialize() {
		commander.parsingCommands();
	}
	
	/**
	 * 
	 * @param id which refers to the specific file
	 * @return returns if the specifil file exists
	 */
	
	public boolean hasLogFileOption(int id) {
		return commander.getFiles()[id] != null;
	}
	
	/**
	 * 
	 * @return returns if an error accured
	 */
	
	public boolean hasError() {
		return commander.getFlag() == 0;
	}
	
	/**
	 * 
	 * @return returns the number of commands 
	 */
	public int getNumberOfCommands() {
		return commander.getCommands().length;
	}
	
	/**
	 * 
	 * @return returns the files
	 */
	public File[] getFiles() {
		return commander.getFiles();
	}
}
